<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="computerRoomList" checkbox="false" fitColumns="true" title="我的实验" actionUrl="computerRoomController.do?roomDeviceApplyInfoListDatagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="申请人"  field="applyUser"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="createDate"  field="createDate" hidden="true" formatter="yyyy-MM-dd" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="deviceId"  field="deviceId" hidden="true" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="hasSendMsg"  field="hasSendMsg" hidden="true" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="状态值"  field="applyStateValue"  hidden="true"  queryMode="single" width="80" ></t:dgCol> 
   <t:dgCol title="computerRoom"  field="computerRoom.id"  hidden="true"  queryMode="single" width="80" ></t:dgCol> 
   <t:dgCol title="是否可以取消"  field="canceled"  hidden="true"  queryMode="single" width="80" ></t:dgCol>
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="实验室名称"  field="computerRoom.name" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="实验室编号"  field="computerRoom.no" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="机床名称"  field="device.machineName" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="机床编号"  field="device.machineNo" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="预约开始日期"  field="applyDate" formatter="yyyy-MM-dd hh:mm" queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="预约结束日期"  field="applyEndDate" formatter="yyyy-MM-dd hh:mm"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="130"></t:dgCol>
   <t:dgFunOpt title="取消预约" funname="cancelOrder(id)" exp="canceled#eq#1"></t:dgFunOpt> 
   <t:dgFunOpt title="修改" funname="selectSeats(id)" exp="applyStateValue#eq#3"></t:dgFunOpt> 
  </t:datagrid>
  </div>
 </div>
 <script src = "webpage/com/mengtian_tech/device_mgr/room/computerRoomList.js"></script>		
 <script type="text/javascript">

function cancelOrder(id){
	  $.dialog.confirm('确定取消预约吗?', function(r) {
	   if (r) { 
			$.ajax({
				url : 'computerRoomController.do?cancelOrder&id='+id,
				type : 'post', 
				cache : false,
				success : function(data) {
					var d = $.parseJSON(data);
					if (d.success) {
						var msg = d.msg;
						tip(msg);
						reloadTable(); 
					}else{
						tip(msg);
					}
				}
			});
		}
	}); 
}
function selectSeats(id, index){
	var rows = $("#computerRoomList").datagrid("getRows");
	var deviceApply = rows[index];
	  var addurl = 'computerRoomController.do?selectSeats&id='+deviceApply['computerRoom.id']+"&deviceApplyId="+id;
	  $.dialog({
		  	id:'selectSeatsDialog',
			content: 'url:'+addurl,
			lock : true,
			zIndex: 1000, 
			width:900,
			height:500,
			title:'设备开放时间设置', 
			opacity : 0.3,
			cache:false,
		    cancelVal: '关闭',
		    cancel: true,
		    close: function(){
		    	$('#computerRoomList').datagrid('reload',{});
		    }
		});
}
 </script>